import uvicorn
from mcp.server.fastmcp import FastMCP
from starlette.applications import Starlette
from starlette.routing import Mount

from application.vk_base_mcp_v2.tool.parser.block_type_mcp_tool import block_type_tool
from application.vk_base_mcp_v2.tool.entity.entity_code_mcp_tool import EntityCodeMcpTool
from application.vk_base_mcp_v2.tool.entity.family_bucket_mcp_tool import family_bucket_tool
from application.vk_base_mcp_v2.tool.common.interface_mcp_tool import interface_tool
from application.vk_base_mcp_v2.prompt.coding_mcp_prompt import VKCodingPrompt
from application.vk_base_mcp_v2.tool.value.value_code_mcp_tool import ValueCodeMCPTool

mcp_server = FastMCP(
    name='tqt-activity-development-basic-mcp-server-vk-v2',
)
# 提示词工具
mcp_server.add_tool(
    fn=VKCodingPrompt.entity_go_prompt,
    name='entity.go编码提示词',
    description='entity.go编码提示词'
)

mcp_server.add_tool(
    fn=VKCodingPrompt.value_go_prompt,
    name='value.go编码提示词',
    description='value.go编码提示词'
)

mcp_server.add_tool(
    fn=VKCodingPrompt.parser_go_prompt,
    name='parser.go编码提示词',
    description='parser.go编码提示词'
)

mcp_server.add_tool(
    fn=VKCodingPrompt.validate_go_prompt,
    name='validate.go编码提示词',
    description='validate.go编码提示词'
)

mcp_server.add_tool(
    fn=VKCodingPrompt.adapter_go_prompt,
    name='adapter.go编码提示词',
    description='validate.go编码提示词'
)

# 开发工具
mcp_server.add_tool(
    fn=EntityCodeMcpTool.handler,
    name='excel工具',
    description='读取excel中的配置项并返回拆分后的配置项markdown'
)

mcp_server.add_tool(
    fn=family_bucket_tool,
    name='全家桶工具',
    description='根据传入的配置项决定是否要复用全家桶'
)

mcp_server.add_tool(
    fn=block_type_tool,
    name='排期工具',
    description='按排期类型决定使用对应的block'
)

mcp_server.add_tool(
    fn=interface_tool,
    name='接口工具',
    description='提供接口名称将返回需要接口详细信息'
)

mcp_server.add_tool(
    fn=ValueCodeMCPTool.handler,
    name='value工具',
    description='提供活动相关信息即可生成value文件'
)

app = Starlette(
    routes=[
        Mount('/', app=mcp_server.sse_app()),
    ]
)

if __name__ == '__main__':
    # 启动前先注释以下代码
    # mcp/server/session.py:161
    uvicorn.run(app, host='127.0.0.1', port=8000)
